<template>
<div class="pulpInfo">
  <el-row v-if="basicInfo">
    <el-col :span="16">
      <el-form :inline="true" :model="basicInfo" label-width="100px" class="demo-ruleForm">
        <el-form-item  label="档案号"><el-input v-model="basicInfo.cardId" disabled ></el-input></el-form-item>
        <el-form-item label="姓名"><el-input v-model="basicInfo.name" disabled></el-input></el-form-item>
        <el-form-item label="身份证号"><el-input v-model="basicInfo.idNo" disabled></el-input></el-form-item>
        <el-form-item label="出生日期" prop="birthday"><el-date-picker v-model="basicInfo.birthday" disabled type="date" placeholder="选择日期"></el-date-picker></el-form-item>
        <el-form-item label="年龄"><el-input v-model="basicInfo.age" disabled></el-input></el-form-item>
        <el-form-item label="性别"><el-input v-model="basicInfo.sexName" disabled></el-input></el-form-item>
        <el-form-item label="电话"><el-input v-model="basicInfo.phone" disabled></el-input></el-form-item>
        <el-form-item label="地址" >
          <el-input class="addressTexrarea" v-model="basicInfo.address" type="textarea" :rows="1" disabled></el-input>
        </el-form-item>
       <el-form-item label="文化水平"><el-select v-model="basicInfo.educationalLevel" class="select200" disabled><el-option v-for="item in codeData8" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
        <el-form-item label="婚姻状态"><el-select v-model="basicInfo.maritalStatus" class="select200" disabled><el-option v-for="item in codeData9" :key="item.code" :value="item.code" :label="item.name"></el-option></el-select></el-form-item>
                <el-form-item label="建档护士"><el-input v-model="basicInfo.createNurseName" disabled></el-input></el-form-item>
      <el-form-item label="建档日期"><el-input v-model="basicInfo.createDate" disabled></el-input></el-form-item>
      </el-form>
    </el-col>
    <el-col :span="8" target="div"  class="pulpWorkImg">
      <img :src="'data:image/png;base64,'+ basicInfo.photo"  class='photoImage'/>
    </el-col>
  </el-row>
</div>
</template>
<script>
import api from 'plugins/axios/api.js';
export default {
 name: "pulpworkInfo",
 props:['cardid','datatype'],
 data(){
    return{
    basicInfo:{},
    sexObj:[],
    type:null,
    }
 },
 created(){
  let self = this;
  
  if(self.datatype!=null&&self.datatype==='provider'){

    self.type = true;
  }else{
    self.type = false;
  }
  api.getCodeData(7).then(res=>{
    self.sexObj=res.content;
  });
  if(self.cardid!=='1'&&self.cardid!= null){
    self.getBasicInfo(self.cardid);
  }else{
  }

 },
 watch:{
    datatype(newCardid,oldCardid){
      if(newCardid==='provider'){
        this.type = true;
      }else{
        this.type = false;
      }
    },
    cardid(newCardid,oldCardid){
      this.basicInfo={};
      if(newCardid!=='1' &&newCardid!= null){
        this.getBasicInfo(newCardid);
      }else{
      }
    },

 },
 methods:{
  getBasicInfo(cardid){
    let self = this;
     if(cardid!=='1'){
       if(self.type){
         let params={
                currentPage:1,
                pageSize:10,
                cardId:cardid,
                providerName:null,
                idNo:null                       
          };
          //查询用户数据，以供义工、浆员框选择使用
           api.providerInfo(params).then(res=>{
               self.basicInfo = res.content.records[0];
               self.sexObj.forEach(sexItem=>{
               if(self.basicInfo.sex==sexItem.code){
                   self.basicInfo.sexName=sexItem.name;
                  }
               })
            },error=>{
            })
       }else{
         api.basicInfo({cardid}).then(res=>{
             self.basicInfo= res.content;
             self.sexObj.forEach(sexItem=>{
               if(self.basicInfo.sex==sexItem.code){
                   self.basicInfo.sexName=sexItem.name;
               }
             })
           });     
       }
     }
  }
 }
}
</script>
<style lang="stylus" scoped>
.pulpInfo 
  .pulpWorkImg
    text-align center
  .addressTexrarea
    width 500px
</style>
